﻿using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

/// <summary>
/// Tools 的摘要说明
/// </summary>
public static class Tools
{
    public static string MD5(string str)
    {
        StringBuilder sb = new StringBuilder(32);
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] t = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
        for (int i = 0; i < t.Length; i++)
        {
            sb.Append(t[i].ToString("x").PadLeft(2, '0'));
        }
        return sb.ToString();
    }

    public static string SHA1(string str)
    {
        return BitConverter.ToString(System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.Default.GetBytes(str))).Replace("-", "").ToLower();
    }
}